package se.jayway.millionaire.client;

import se.jayway.millionaire.engine.Configuration;
import se.jayway.millionaire.engine.GameManager;

public class Main {
	public static void main(String[] args) {
		if (args.length < 2) {
			throw new IllegalArgumentException("Missing database-file number-of-players arguments");
		}

		Configuration.getInstance().setDatabaseFileName(args[0]);
		
		int numberOfPlayers = 0;
		try {
			numberOfPlayers = Integer.parseInt(args[1]);
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException("Argument " + args[1] + " is not a number", e);
		}

		// Start the game
		GameManager game = GameManager.getInstance();
		game.start();

		// Simulate some players
		for (int i = 0; i < numberOfPlayers; i++) {
			RandomPlayer player = new RandomPlayer("Player" + i);
			game.addGameListener(player);
		}
	}
}
